package com.lqian.demo02.part1;

import com.lqian.demo02.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * @author：Melody_LQ
 * @time：2022/7/13 2:08 下午
 */
public class TestJDBCDemo {

    public static void main(String[] args) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;
        //获取数据库连接
        try {
            conn = JDBCUtils.getConnection();
        //通过conn对象获取负责执行sql命令的statement对象
        st = conn.createStatement();
        //sql命令
        String sql = "insert into users(id,name,password,email,birthday)" +
                "values(4,'kuangshen','123','24736743@qq.com','2020-01-01')";
        //执行插入操作，executeUpdate方法返回成功的条数
        int resultRow = st.executeUpdate(sql);
        if (resultRow > /**/0){
           System.out.println("插入成功");
        }
    }catch (Exception e){
            e.printStackTrace();
    }finally {
            //SQL执行完成之后释放相关资源
            JDBCUtils.release(conn,st,rs);
        }
        }


}
